/**
 * Created by Administrator on 2016/8/4.
 */

/*$(function(){
 layer.msg('您打开了页面');
 })*/

//表单事件,点击submit执行回调函数
$('form').submit(function (e) {
    //阻止表单默认行为
    e.preventDefault();
    //serialize收集表单上数据
    var data = $(this).serialize();
    if ($('input[name=password]').val() === $('input[name=rpassword]').val()) {
        //post AJAX操作
        console.log(data);
        $.post('/register', data, function (data) {
            var _message = data.message;
            layer.msg(_message, function () {
                if (data.code == 'success') {
                    location.href = 'index.html';
                }
            });
        })
    } else {
        layer.msg('密码不一致');
    }
});
